package com.huntech.data;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.util.unit.DataSize;
import org.springframework.util.unit.DataUnit;

import javax.servlet.MultipartConfigElement;
import java.io.File;

@SpringBootApplication
public class EFileToExcelApplication {

	public static void main(String[] args) {
		SpringApplication.run(EFileToExcelApplication.class, args);
	}


	@Bean
	public MultipartConfigElement multipartConfigElement() {
		MultipartConfigFactory factory = new MultipartConfigFactory();
		//文件最大
		factory.setMaxFileSize(DataSize.of(1073741824L , DataUnit.KILOBYTES)); //KB,MB
		/// 设置总上传数据总大小
		factory.setMaxRequestSize(DataSize.of(1073741824L , DataUnit.KILOBYTES));
		factory.setLocation("D:\\"); //临时文件存储目录
		//factory.setLocation("E:\\wordtest"); //临时文件存储目录
		File file = new File("D:\\");
		if(!file.exists()){
			file.mkdirs();
		}
		//factory.setLocation("E:\\wordtest"); //临时文件存储目录
		return factory.createMultipartConfig();
	}

}
